package com.yisoo.ubag.product.controller;

import java.util.Arrays;
import java.util.Map;

import com.yisoo.ubag.product.entity.DevTokenEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.yisoo.ubag.product.entity.DevEntity;
import com.yisoo.ubag.product.service.DevService;
import com.yisoo.common.utils.PageUtils;
import com.yisoo.common.utils.R;



/**
 * 
 *
 * @author mmciel
 * @email 761998179@qq.com
 * @date 2021-02-06 17:43:43
 */
@RestController
@RequestMapping("product/dev")
public class DevController {
    @Autowired
    private DevService devService;




    /**
     * 快速导入
     */
    @PostMapping("/import/{num}")
    public R add(@PathVariable("num") Integer num ,@RequestBody DevTokenEntity devToken){

//        System.out.println(devToken);

        return  devService.quickImport(devToken,num);
    }


    /**
     * 列表
     */
    @RequestMapping("/list")
    //@RequiresPermissions("product:dev:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = devService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{devId}")
    //@RequiresPermissions("product:dev:info")
    public R info(@PathVariable("devId") Long devId){
		DevEntity dev = devService.getById(devId);

        return R.ok().put("dev", dev);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    //@RequiresPermissions("product:dev:save")
    public R save(@RequestBody DevEntity dev){
		devService.save(dev);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    //@RequiresPermissions("product:dev:update")
    public R update(@RequestBody DevEntity dev){
		devService.updateById(dev);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    //@RequiresPermissions("product:dev:delete")
    public R delete(@RequestBody Long[] devIds){
		devService.removeByIds(Arrays.asList(devIds));

        return R.ok();
    }

}
